<template>
  <div class="product-list">
    <div
      class="item"
      v-for="item in itemLists"
      :key="item.goodsId"
      @click="toDetail(item.goodsId)"
    >
      <div class="item-box">
        <div class="pimg">
          <van-image class="pic" :src="item.defaultImages" />
        </div>
        <div class="name">{{ item.goodsName }}</div>
        <div class="bottom">
          <div class="score-num">
            <em>{{ item.creditsNum }}</em
            >积分
          </div>
          <span class="btn">兑换</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "IndexItem",
  props: {
    itemLists: Array,
  },
  created() {},
  methods: {
    toDetail(id) {
      let query = {
        id,
      };
      this.$router.push({ path: "/productDetail", query });
    },
  },
};
</script>
<style scoped lang="less">
.product-list {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  padding: 15px;
  flex-wrap: wrap;
}
.item {
  width: 50%;
  &-box {
    margin: 4px;
    padding-bottom: 10px;
    background: #fff;
    border-radius: 12px;
  }
  .pimg {
    height: 165px;
    text-align: center;
    .pic {
      height: 165px;
    }
  }
  .name {
    margin: 6px 12px;
    height: 40px;
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .bottom {
    display: flex;
    padding: 0 12px;
    .score-num {
      flex: 1;
      font-size: 12px;
      color: #51afb1;
      em {
        padding-right: 2px;
        font-size: 20px;
      }
    }
    .btn {
      padding: 0 8px;
      height: 24px;
      line-height: 24px;
      margin-top: 4px;
      font-size: 12px;
      color: #fff;
      background: #51afb1;
      border-radius: 4px;
    }
  }
}
</style>
